package com.situ.day3;

import org.junit.Test;

public class WhileForDemo {

    @Test
    public void test1() {
        int i = 1;
        while (i <= 5) {
            System.out.println("HelloWord");
            i++;
        }
    }

    @Test
    public void test2() {
        for (int i = 1; i <= 5; i++) {
            System.out.println("HelloWord");
        }
    }

    //累加思想（1+2+3+... + 100）
    @Test
    public void test4() {
        int sum = 0;
        for (int i = 1; i <= 100; i++) {
            //System.out.println(i);
            //sum = sum + i;
            sum += i;
            //System.out.println("sum: " + sum);
        }
        System.out.println("sum: " + sum);
    }

    //统计思想，数一下符合条件的有多少个（计算1-100以内7的倍数的个数）
    //7、14、21
    @Test
    public void test41() {
        int count = 0;
        for (int i = 1; i <= 100; i++) {
            if (i % 7 == 0) {
                System.out.println(i);
                count++;
            }
        }
        System.out.println("count: " + count);
    }
}
